42 sfg->SV_1DOF_P_BASIC.resetflag =
true;
45 sfg->SV_3DOF_B_BASIC.resetflag =
true;
48 sfg->SV_3DOF_G_BASIC.resetflag =
true;
51 sfg->SV_3DOF_Y_BASIC.resetflag =
true;
54 sfg->SV_6DOF_GB_BASIC.resetflag =
true;
57 sfg->SV_6DOF_GY_KALMAN.resetflag =
true;
60 sfg->SV_9DOF_GBY_KALMAN.resetflag =
true;
83 if (pthisSV_1DOF_P_BASIC)
93 if (pthisSV_3DOF_G_BASIC)
103 if (pthisSV_3DOF_B_BASIC)
113 if (pthisSV_3DOF_Y_BASIC)
123 if (pthisSV_6DOF_GB_BASIC)
133 if (pthisSV_6DOF_GY_KALMAN)
142 #if F_9DOF_GBY_KALMAN 143 if (pthisSV_9DOF_GBY_KALMAN)
147 pthisGyro, pthisMagCal);
164 if (flpftimesecs > pthisSV->
fdeltat)
167 pthisSV->
flpf = 1.0F;
170 pthisSV->
fLPH = pthisPressure->
fH;
171 pthisSV->
fLPT = pthisPressure->
fT;
180 struct AccelSensor *pthisAccel,
float flpftimesecs)
186 if (flpftimesecs > pthisSV->
fdeltat)
189 pthisSV->
flpf = 1.0F;
192 #if THISCOORDSYSTEM == NED 194 #elif THISCOORDSYSTEM == ANDROID 208 struct MagSensor *pthisMag,
float flpftimesecs)
214 if (flpftimesecs > pthisSV->
fdeltat)
217 pthisSV->
flpf = 1.0F;
220 #if THISCOORDSYSTEM == NED 222 #elif THISCOORDSYSTEM == ANDROID 252 struct MagSensor *pthisMag,
float flpftimesecs)
260 if (flpftimesecs > pthisSV->
fdeltat)
263 pthisSV->
flpf = 1.0F;
266 #if THISCOORDSYSTEM == NED 268 #elif THISCOORDSYSTEM == ANDROID 299 for (i =
CHX; i <=
CHZ; i++)
309 if (*((
uint32 *) pFlash++) == 0x12345678)
312 for (i =
CHX; i <=
CHZ; i++) pthisSV->
fbPl[i] = *(pFlash++);
318 for (i =
CHX; i <=
CHZ; i++)
322 pthisSV->
fbPl[i] = pthisGyro->
fYs[i];
324 pthisSV->
fbPl[i] = 0.0F;
330 #if THISCOORDSYSTEM == NED 332 #elif THISCOORDSYSTEM == ANDROID 364 for (i =
CHX; i <=
CHZ; i++) {
368 pthisSV->
fVelGl[i] = 0.0F;
369 pthisSV->
fDisGl[i] = 0.0F;
376 if (*((
uint32*) pFlash++) == 0x12345678) {
378 for (i =
CHX; i <=
CHZ; i++)
379 pthisSV->
fbPl[i] = *(pFlash++);
383 for (i =
CHX; i <=
CHZ; i++) {
385 pthisSV->
fbPl[i] = pthisGyro->
fYs[i];
387 pthisSV->
fbPl[i] = 0.0F;
395 #if THISCOORDSYSTEM == NED 397 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
398 #elif THISCOORDSYSTEM == ANDROID 400 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
403 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
432 pthisSV->
fLPH += pthisSV->
flpf * (pthisPressure->
fH - pthisSV->
fLPH);
433 pthisSV->
fLPT += pthisSV->
flpf * (pthisPressure->
fT - pthisSV->
fLPT);
450 #if THISCOORDSYSTEM == NED 452 #elif THISCOORDSYSTEM == ANDROID 468 #if THISCOORDSYSTEM == NED 472 #elif THISCOORDSYSTEM == ANDROID 499 #if THISCOORDSYSTEM == NED 501 #elif THISCOORDSYSTEM == ANDROID 517 #if THISCOORDSYSTEM == NED 521 #elif THISCOORDSYSTEM == ANDROID 565 #if THISCOORDSYSTEM == NED 568 &(pthisSV->
fRho), &(pthisSV->
fChi));
569 #elif THISCOORDSYSTEM == ANDROID 572 &(pthisSV->
fRho), &(pthisSV->
fChi));
576 &(pthisSV->
fRho), &(pthisSV->
fChi));
585 float ftmp1, ftmp2, ftmp3, ftmp4;
596 #if THISCOORDSYSTEM == NED 598 #elif THISCOORDSYSTEM == ANDROID 614 #if THISCOORDSYSTEM == NED 618 #elif THISCOORDSYSTEM == ANDROID 641 float ftmp3DOF3x1[3];
642 float ftmpA3x3[3][3];
669 for (i =
CHX; i <=
CHZ; i++)
670 pthisSV->
fOmega[i] = (
float) pthisGyro->
iYs[i] *
676 fqMi = pthisSV->
fqPl;
686 for (i =
CHX; i <=
CHZ; i++)
687 ftmpMi3x1[i] = (
float) pthisGyro->
iYsFIFO[j][i] *
706 fmodGc = sqrtf(fabs(pthisAccel->
fGc[
CHX] * pthisAccel->
fGc[
CHX] +
712 ftmp = 1.0F / fmodGc;
713 ftmp3DOF3x1[
CHX] = pthisAccel->
fGc[
CHX] * ftmp;
714 ftmp3DOF3x1[
CHY] = pthisAccel->
fGc[
CHY] * ftmp;
715 ftmp3DOF3x1[
CHZ] = pthisAccel->
fGc[
CHZ] * ftmp;
720 ftmp3DOF3x1[
CHX] = 0.0F;
721 ftmp3DOF3x1[
CHY] = 0.0F;
722 ftmp3DOF3x1[
CHZ] = 1.0F;
726 #if THISCOORDSYSTEM == NED 728 #elif THISCOORDSYSTEM == ANDROID 730 ftmp3DOF3x1[
CHX] = -ftmp3DOF3x1[
CHX];
731 ftmp3DOF3x1[
CHY] = -ftmp3DOF3x1[
CHY];
732 ftmp3DOF3x1[
CHZ] = -ftmp3DOF3x1[
CHZ];
738 ftmpMi3x1[
CHX] = 2.0F * (fqMi.
q1 * fqMi.
q3 - fqMi.
q0 * fqMi.
q2);
739 ftmpMi3x1[
CHY] = 2.0F * (fqMi.
q2 * fqMi.
q3 + fqMi.
q0 * fqMi.
q1);
740 ftmpMi3x1[
CHZ] = 2.0F * (fqMi.
q0 * fqMi.
q0 + fqMi.
q3 * fqMi.
q3) - 1.0F;
743 #if THISCOORDSYSTEM == NED 745 #else // ANDROID and WIN8 747 ftmpMi3x1[
CHX] = -ftmpMi3x1[
CHX];
748 ftmpMi3x1[
CHY] = -ftmpMi3x1[
CHY];
749 ftmpMi3x1[
CHZ] = -ftmpMi3x1[
CHZ];
763 for (i = 0; i < 6; i++)
764 for (j = 0; j < 6; j++) pthisSV->
fQw6x6[i][j] = 0.0F;
808 ftmp = fmodGc - 1.0F;
809 fQvGQa = 3.0F * ftmp * ftmp;
815 for (i = 0; i < 6; i++)
817 for (j = 0; j < 3; j++)
822 for (k = 0; k < 6; k++)
826 if (k == j) fC3x6jk = 1.0F;
830 if ((pthisSV->
fQw6x6[i][k] != 0.0F) && (fC3x6jk != 0.0F))
842 for (i = 0; i < 3; i++)
844 for (j = i; j < 3; j++)
848 ftmpA3x3[i][j] = pthisSV->
fQv;
850 ftmpA3x3[i][j] = 0.0F;
853 for (k = 0; k < 6; k++)
857 if (k == i) fC3x6ik = 1.0F;
861 if ((fC3x6ik != 0.0F) && (pthisSV->
fQwCT6x3[k][j] != 0.0F))
864 ftmpA3x3[i][j] += pthisSV->
fQwCT6x3[k][j];
866 ftmpA3x3[i][j] += fC3x6ik * pthisSV->
fQwCT6x3[k][j];
873 ftmpA3x3[1][0] = ftmpA3x3[0][1];
874 ftmpA3x3[2][0] = ftmpA3x3[0][2];
875 ftmpA3x3[2][1] = ftmpA3x3[1][2];
878 for (i = 0; i < 3; i++) pfRows[i] = ftmpA3x3[i];
885 for (i = 0; i < 6; i++)
887 for (j = 0; j < 3; j++)
889 pthisSV->
fK6x3[i][j] = 0.0F;
890 for (k = 0; k < 3; k++)
892 if ((pthisSV->
fQwCT6x3[i][k] != 0.0F) &&
893 (ftmpA3x3[k][j] != 0.0F))
895 pthisSV->
fK6x3[i][j] += pthisSV->
fQwCT6x3[i][k] * ftmpA3x3[k][j];
904 for (i = 0; i < 6; i++)
906 for (j = 0; j < 3; j++)
908 pthisSV->
fK6x3[i][j] = 0.0F;
915 for (i =
CHX; i <=
CHZ; i++)
924 if (pthisSV->
fK6x3[i][CHZ] != 0.0F)
928 if (pthisSV->
fK6x3[i + 3][
CHX] != 0.0F)
932 if (pthisSV->
fK6x3[i + 3][
CHY] != 0.0F)
934 if (pthisSV->
fK6x3[i + 3][CHZ] != 0.0F)
942 ftmp = ftmpq.
q1 * ftmpq.
q1 + ftmpq.
q2 * ftmpq.
q2 + ftmpq.
q3 * ftmpq.
q3;
948 ftmpq.
q0 = sqrtf(fabsf(1.0F - ftmp));
953 ftmp = 1.0F / sqrtf(ftmp);
970 for (i =
CHX; i <=
CHZ; i++)
986 #if THISCOORDSYSTEM == NED 991 #elif THISCOORDSYSTEM == ANDROID 1002 #if THISCOORDSYSTEM == NED 1006 #elif THISCOORDSYSTEM == ANDROID 1017 #if F_9DOF_GBY_KALMAN 1026 float ftmpA6x6[6][6];
1033 float ftmpA3x3[3][3];
1043 float fsinDelta6DOF;
1044 float fcosDelta6DOF;
1070 fqMi = pthisSV->
fqPl;
1076 for (j = 0; j < pthisGyro->
iFIFOCount; j++) {
1095 #if THISCOORDSYSTEM == NED 1096 feCompassNED(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1097 #elif THISCOORDSYSTEM == ANDROID 1098 feCompassAndroid(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1100 feCompassWin8(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1107 ftmp = fmodGc - 1.0F;
1108 fQvGQa = 3.0F * ftmp * ftmp;
1113 ftmp = fmodBc - pthisMagCal->
fB;
1114 fQvBQd = 3.0F * ftmp * ftmp;
1122 fqMi = pthisSV->
fqPl = fq6DOF;
1132 #if THISCOORDSYSTEM == NED 1139 #else // ANDROID and WIN8 (ENU gravity positive) 1157 #if THISCOORDSYSTEM == NED 1158 ftmpA3x1[
CHX] = fR6DOF[
CHX][
CHX] * fcosDelta6DOF + fR6DOF[
CHX][
CHZ] * fsinDelta6DOF;
1159 ftmpA3x1[
CHY] = fR6DOF[
CHY][
CHX] * fcosDelta6DOF + fR6DOF[
CHY][
CHZ] * fsinDelta6DOF;
1160 ftmpA3x1[
CHZ] = fR6DOF[
CHZ][
CHX] * fcosDelta6DOF + fR6DOF[
CHZ][
CHZ] * fsinDelta6DOF;
1164 #else // ANDROID and WIN8 (both ENU coordinate systems) 1165 ftmpA3x1[
CHX] = fR6DOF[
CHX][
CHY] * fcosDelta6DOF - fR6DOF[
CHX][
CHZ] * fsinDelta6DOF;
1166 ftmpA3x1[
CHY] = fR6DOF[
CHY][
CHY] * fcosDelta6DOF - fR6DOF[
CHY][
CHZ] * fsinDelta6DOF;
1167 ftmpA3x1[
CHZ] = fR6DOF[
CHZ][
CHY] * fcosDelta6DOF - fR6DOF[
CHZ][
CHZ] * fsinDelta6DOF;
1184 for (i = 0; i < 9; i++)
1185 for (j = i; j < 9; j++)
1186 pthisSV->
fQw9x9[i][j] = 0.0F;
1220 for (i = 1; i < 9; i++)
1221 for (j = 0; j < i; j++)
1230 for (i = 0; i < 9; i++) {
1231 for (j = 0; j < 6; j++) {
1234 for (k = 0; k < 9; k++) {
1239 if (k == j) fC6x9jk = 1.0F;
1240 if (k == (j + 6)) fC6x9jk = -pthisSV->
fAlphaOver2;
1243 if (k == j) fC6x9jk = 1.0F;
1244 if (k == (j + 3)) fC6x9jk = -pthisSV->
fAlphaOver2;
1248 if ((pthisSV->
fQw9x9[i][k] != 0.0F) && (fC6x9jk != 0.0F)) {
1249 if (fC6x9jk == 1.0F) pthisSV->
fQwCT9x6[i][j] += pthisSV->
fQw9x9[i][k];
1257 for (i = 0; i < 6; i++) {
1258 for (j = i; j < 6; j++) {
1260 if (i == j) ftmpA6x6[i][j] = pthisSV->
fQv6x1[i];
1261 else ftmpA6x6[i][j] = 0.0F;
1263 for (k = 0; k < 9; k++) {
1268 if (k == i) fC6x9ik = 1.0F;
1269 if (k == (i + 6)) fC6x9ik = -pthisSV->
fAlphaOver2;
1272 if (k == i) fC6x9ik = 1.0F;
1273 if (k == (i + 3)) fC6x9ik = -pthisSV->
fAlphaOver2;
1277 if ((fC6x9ik != 0.0F) && (pthisSV->
fQwCT9x6[k][j] != 0.0F)) {
1278 if (fC6x9ik == 1.0F) ftmpA6x6[i][j] += pthisSV->
fQwCT9x6[k][j];
1279 else ftmpA6x6[i][j] += fC6x9ik * pthisSV->
fQwCT9x6[k][j];
1285 for (i = 1; i < 6; i++)
1286 for (j = 0; j < i; j++)
1287 ftmpA6x6[i][j] = ftmpA6x6[j][i];
1290 for (i = 0; i < 6; i++)
1291 pfRows[i] = ftmpA6x6[i];
1297 for (i = 0; i < 9; i++)
1298 for (j = 0; j < 6; j++) {
1299 pthisSV->
fK9x6[i][j] = 0.0F;
1300 for (k = 0; k < 6; k++) {
1301 if ((pthisSV->
fQwCT9x6[i][k] != 0.0F) && (ftmpA6x6[k][j] != 0.0F))
1302 pthisSV->
fK9x6[i][j] += pthisSV->
fQwCT9x6[i][k] * ftmpA6x6[k][j];
1307 for (i = 0; i < 9; i++)
1308 for (j = 0; j < 6; j++)
1309 pthisSV->
fK9x6[i][j] = 0.0F;
1314 for (i =
CHX; i <=
CHZ; i++) {
1316 for (j = 0; j < 6; j++) {
1318 if (pthisSV->
fK9x6[i][j] != 0.0F)
1322 if (pthisSV->
fK9x6[i + 3][j] != 0.0F)
1326 if (pthisSV->
fK9x6[i + 6][j] != 0.0F)
1335 ftmpq.
q0 = sqrtf(fabs(1.0F - ftmpq.
q1 * ftmpq.
q1 - ftmpq.
q2 * ftmpq.
q2 - ftmpq.
q3 * ftmpq.
q3));
1340 fveqRu(fgPl, ftmpA3x3, fgMi, 0);
1346 ftmpq.
q0 = sqrtf(fabs(1.0F - ftmpq.
q1 * ftmpq.
q1 - ftmpq.
q2 * ftmpq.
q2 - ftmpq.
q3 * ftmpq.
q3));
1351 fveqRu(fmPl, ftmpA3x3, fmMi, 0);
1355 #if THISCOORDSYSTEM == NED// gravity vector is +z and accel measurement is +z when flat so don't negate 1357 fmPl, fgPl, &fmodBc, &fmodGc);
1358 #elif THISCOORDSYSTEM == ANDROID // gravity vector is -z and accel measurement is +z when flat so negate 1359 ftmpA3x1[
CHX] = -fgPl[
CHX];
1360 ftmpA3x1[
CHY] = -fgPl[
CHY];
1361 ftmpA3x1[
CHZ] = -fgPl[
CHZ];
1363 fmPl, ftmpA3x1, &fmodBc, &fmodGc);
1364 #else // WIN8// gravity vector is -z and accel measurement is -1g when flat so don't negate 1366 fmPl, fgPl, &fmodBc, &fmodGc);
1374 for (i =
CHX; i <=
CHZ; i++) {
1393 #if THISCOORDSYSTEM == NED 1398 #elif THISCOORDSYSTEM == ANDROID 1411 for (i =
CHX; i <=
CHZ; i++) {
1419 #if THISCOORDSYSTEM == NED 1421 #elif THISCOORDSYSTEM == ANDROID 1429 #endif // #if F_9DOF_GBY_KALMAN float fLPThe
low pass pitch (deg)
float flpf
low pass filter coefficient
Quaternion fqPl
a posteriori orientation quaternion
int32_t systick
systick timer
float fLPR[3][3]
low pass filtered orientation matrix
float fOmega[3]
average angular velocity (deg/s)
void fRotationVectorDegFromQuaternion(Quaternion *pq, float rvecdeg[])
computes rotation vector (deg) from rotation quaternion
#define FLPFSECS_3DOF_G_BASIC
tilt orientation low pass filter time constant (s)
The PressureSensor structure stores raw and processed measurements for an altimeter.
float fbPl[3]
gyro offset (deg/s)
float fcosDeltaPl
cos(fDeltaPl)
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
void f3DOFMagnetometerMatrixAndroid(float fR[][3], float fBc[])
Android magnetometer 3DOF flat eCompass function, computing rotation matrix fR.
float q3
z vector component
void f3DOFTiltAndroid(float fR[][3], float fGc[])
Android accelerometer 3DOF tilt function computing, rotation matrix fR.
float fK9x6[9][6]
kalman filter gain matrix K
#define FMIN_9DOF_GBY_BPL
minimum permissible power on gyro offsets (deg/s)
float fRPl[3][3]
a posteriori orientation matrix
void fInit_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag, float flpftimesecs)
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
float fbPl[3]
gyro offset (deg/s)
void fLPFOrientationQuaternion(Quaternion *pq, Quaternion *pLPq, float flpf, float fdeltat, float fOmega[])
function low pass filters an orientation quaternion and computes virtual gyro rotation rate ...
float fqgErrPl[3]
gravity vector tilt orientation quaternion error (dimensionless)
The SV_1DOF_P_BASIC structure contains state information for a pressure sensor/altimeter.
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
void f3DOFMagnetometerMatrixNED(float fR[][3], float fBc[])
Aerospace NED magnetometer 3DOF flat eCompass function, computing rotation matrix fR...
void f3x3matrixAeqI(float A[][3])
function sets the 3x3 matrix A to the identity matrix
float fAccGl[3]
linear acceleration (g) in global frame
float fQw6x6[6][6]
covariance matrix Qw
float fDeltaPl
a posteriori inclination angle from Kalman filter (deg)
void feCompassNED(float fR[][3], float *pfDelta, float *pfsinDelta, float *pfcosDelta, float fBc[], float fGc[], float *pfmodBc, float *pfmodGc)
NED: basic 6DOF e-Compass function, computing rotation matrix fR and magnetic inclination angle fDelt...
float fRPl[3][3]
a posteriori orientation matrix
float fBSq
square of fB (uT^2)
float fGc[3]
averaged precision calibrated measurement (g)
int32_t iValidMagCal
solver used: 0 (no calibration) or 4, 7, 10 element
float fRhoPl
compass (deg)
SV_6DOF_GY_KALMAN is the 6DOF Kalman filter accelerometer and gyroscope state vector structure...
int32 ARM_systick_elapsed_ticks(int32 start_ticks)
#define FQWB_9DOF_GBY_KALMAN
gyro offset random walk units (deg/s)^2
float q1
x vector component
float fRVecPl[3]
rotation vector
void feCompassWin8(float fR[][3], float *pfDelta, float *pfsinDelta, float *pfcosDelta, float fBc[], float fGc[], float *pfmodBc, float *pfmodGc)
Win8: basic 6DOF e-Compass function, computing rotation matrix fR and magnetic inclination angle fDel...
This is the 3DOF basic magnetometer state vector structure/.
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
void fveqRu(float fv[], float fR[][3], float fu[], int8 itranspose)
void fInitializeFusion(SensorFusionGlobals *sfg)
#define FUSION_HZ
(int) actual rate of fusion algorithm execution and sensor FIFO reads
void fRun_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV, struct GyroSensor *pthisGyro)
#define FQWB_6DOF_GY_KALMAN
gyro offset random walk units (deg/s)^2
void fInit_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
int32_t systick
systick timer;
void fRotationMatrixFromQuaternion(float R[][3], const Quaternion *pq)
compute the rotation matrix from an orientation quaternion
#define CHX
Used to access X-channel entries in various data data structures.
int8_t resetflag
flag to request re-initialization on next pass
int8_t resetflag
flag to request re-initialization on next pass
float fLPRVec[3]
rotation vector
float fLPDelta
low pass filtered inclination angle (deg)
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
Defines control sub-system.
void f3x3matrixAeqB(float A[][3], float B[][3])
function sets 3x3 matrix A to 3x3 matrix B
void fFuseSensors(struct SV_1DOF_P_BASIC *pthisSV_1DOF_P_BASIC, struct SV_3DOF_G_BASIC *pthisSV_3DOF_G_BASIC, struct SV_3DOF_B_BASIC *pthisSV_3DOF_B_BASIC, struct SV_3DOF_Y_BASIC *pthisSV_3DOF_Y_BASIC, struct SV_6DOF_GB_BASIC *pthisSV_6DOF_GB_BASIC, struct SV_6DOF_GY_KALMAN *pthisSV_6DOF_GY_KALMAN, struct SV_9DOF_GBY_KALMAN *pthisSV_9DOF_GBY_KALMAN, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct PressureSensor *pthisPressure, struct MagCalibration *pthisMagCal)
void fQuaternionFromRotationMatrix(float R[][3], Quaternion *pq)
compute the orientation quaternion from a 3x3 rotation matrix
void fqAeq1(Quaternion *pqA)
set a quaternion to the unit quaternion
float fQwCT9x6[9][6]
Qw.C^T matrix.
#define FQVY_6DOF_GY_KALMAN
gyro sensor noise variance units (deg/s)^2
float fQv6x1[6]
measurement noise covariance matrix leading diagonal
float fAlphaOver2
PI / 180 * fdeltat / 2.
Provides function prototypes for driver level interfaces.
float fLPRho
low pass compass (deg)
void fNEDAnglesDegFromRotationMatrix(float R[][3], float *pfPhiDeg, float *pfTheDeg, float *pfPsiDeg, float *pfRhoDeg, float *pfChiDeg)
extract the NED angles in degrees from the NED rotation matrix
Quaternion fLPq
low pass filtered orientation quaternion
SV_6DOF_GB_BASIC is the 6DOF basic accelerometer and magnetometer state vector structure.
int32_t loopcounter
counter incrementing each iteration of sensor fusion (typically 25Hz)
float fDegPerSecPerCount
deg/s per count
int16_t iYsFIFO[GYRO_FIFO_SIZE][3]
FIFO measurements (counts)
int8_t resetflag
flag to request re-initialization on next pass
int32_t systick
systick timer
float fLPRVec[3]
rotation vector
void fRun_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure)
float fLPRVec[3]
rotation vector
void feCompassAndroid(float fR[][3], float *pfDelta, float *pfsinDelta, float *pfcosDelta, float fBc[], float fGc[], float *pfmodBc, float *pfmodGc)
Android: basic 6DOF e-Compass function, computing rotation matrix fR and magnetic inclination angle f...
Functions to convert between various orientation representations.
void qAeqAxB(Quaternion *pqA, const Quaternion *pqB)
function compute the quaternion product qA = qA * qB
float fR[3][3]
unfiltered orientation matrix
void f3DOFTiltNED(float fR[][3], float fGc[])
Aerospace NED accelerometer 3DOF tilt function, computing rotation matrix fR.
#define FPIOVER180
degrees to radians conversion = pi / 180
void qAeqBxC(Quaternion *pqA, const Quaternion *pqB, const Quaternion *pqC)
function compute the quaternion product qB * qC
float fRVec[3]
rotation vector
float fLPRho
low pass compass (deg)
Quaternion fLPq
low pass filtered orientation quaternion
float fVelGl[3]
velocity (m/s) in global frame
float fZErr[3]
measurement error vector
Lower level sensor fusion interface.
int8_t resetflag
flag to request re-initialization on next pass
#define FMIN_6DOF_GY_BPL
minimum permissible power on gyro offsets (deg/s)
float fR[3][3]
unfiltered orientation matrix
#define FQVG_9DOF_GBY_KALMAN
accelerometer sensor noise variance units g^2 defining minimum deviation from 1g sphere ...
#define FMAX_6DOF_GY_BPL
maximum permissible power on gyro offsets (deg/s)
float fRVecPl[3]
rotation vector
float fBc[3]
averaged calibrated measurement (uT)
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
float fT
most recent unaveraged temperature (C)
float fLPChi
low pass tilt from vertical (deg)
Quaternion fLPq
low pass filtered orientation quaternion
void fInit_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal)
#define CHY
Used to access Y-channel entries in various data data structures.
float q2
y vector component
float fLPT
low pass filtered temperature (C)
uint8_t iFIFOCount
number of measurements read from FIFO
float fOmega[3]
angular velocity (deg/s)
void fInit_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure, float flpftimesecs)
void fRun_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
void fInit_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, float flpftimesecs)
void fInit_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel, float flpftimesecs)
float fChi
tilt from vertical (deg)
The top level fusion structure.
int8_t resetflag
flag to request re-initialization on next pass
#define FQVB_9DOF_GBY_KALMAN
magnetometer sensor noise variance units uT^2 defining minimum deviation from geomagnetic sphere...
#define FLPFSECS_3DOF_B_BASIC
2D eCompass orientation low pass filter time constant (s)
float fH
most recent unaveraged height (m)
The sensor_fusion.h file implements the top level programming interface.
float fAccGl[3]
linear acceleration (g) in global frame
void f3DOFMagnetometerMatrixWin8(float fR[][3], float fBc[])
Windows 8 magnetometer 3DOF flat eCompass function, computing rotation matrix fR. ...
float fQwCT6x3[6][3]
Qw.C^T matrix.
#define CALIBRATION_NVM_ADDR
start of final 4K (sector size) of 1M flash
float fdeltat
fusion filter sampling interval (s)
int8_t iFirstAccelMagLock
denotes that 9DOF orientation has locked to 6DOF eCompass
float fLPChi
low pass tilt from vertical (deg)
float fdeltat
fusion time interval (s)
void fqAeqNormqA(Quaternion *pqA)
function normalizes a rotation quaternion and ensures q0 is non-negative
int32_t systick
systick timer
float fdeltat
fusion time interval (s)
float fLPThe
low pass pitch (deg)
#define CHZ
Used to access Z-channel entries in various data data structures.
float fOmega[3]
virtual gyro angular velocity (deg/s)
float fLPPhi
low pass roll (deg)
Matrix manipulation functions.
float flpf
low pass filter coefficient
quaternion structure definition
void f3DOFTiltWin8(float fR[][3], float fGc[])
Windows 8 accelerometer 3DOF tilt function computing, rotation matrix fR.
void fRun_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag)
float fB
current geomagnetic field magnitude (uT)
void fInit_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV)
#define FMAX_9DOF_GBY_BPL
maximum permissible power on gyro offsets (deg/s)
float fDisGl[3]
displacement (m) in global frame
void fmatrixAeqInvA(float *A[], int8 iColInd[], int8 iRowInd[], int8 iPivot[], int8 isize, int8 *pierror)
#define FQVY_9DOF_GBY_KALMAN
gyro sensor noise variance units (deg/s)^2
void fRun_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct MagSensor *pthisMag, struct AccelSensor *pthisAccel)
float fgdeltat
g (m/s2) * fdeltat
float fR[3][3]
unfiltered orientation matrix
float fLPH
low pass filtered height (m)
float fsinDeltaPl
sin(fDeltaPl)
float fbErrPl[3]
gyro offset error (deg/s)
float fdeltat
fusion time interval (s)
float fQv
measurement noise covariance matrix leading diagonal
float fLPThe
low pass pitch (deg)
float fLPRho
low pass compass (deg)
float fZErr[6]
measurement error vector
#define FQVG_6DOF_GY_KALMAN
accelerometer sensor noise variance units g^2
float fLPPsi
low pass yaw (deg)
float flpf
low pass filter coefficient
Quaternion fq
unfiltered orientation quaternion
float fLPPsi
low pass yaw (deg)
float fLPPhi
low pass roll (deg)
The AccelSensor structure stores raw and processed measurements for a 3-axis accelerometer.
float fOmega[3]
angular velocity (deg/s)
#define FLPFSECS_1DOF_P_BASIC
pressure low pass filter time constant (s)
float fqmErrPl[3]
geomagnetic vector tilt orientation quaternion error (dimensionless)
int8_t resetflag
flag to request re-initialization on next pass
float fYs[3]
averaged measurement (deg/s)
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
float fqgErrPl[3]
gravity vector tilt orientation quaternion error (dimensionless)
float fdeltat
fusion time interval (s)
void fveqconjgquq(Quaternion *pfq, float fu[], float fv[])
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
int32_t systick
systick timer;
float fdeltat
sensor fusion interval (s)
float fLPChi
low pass tilt from vertical (deg)
float fbErrPl[3]
gyro offset error (deg/s)
Quaternion fq
unfiltered orientation quaternion
float fLPPsi
low pass yaw (deg)
float fLPPhi
low pass roll (deg)
int32_t systick
systick timer
float fOmega[3]
average angular velocity (deg/s)
void fAndroidAnglesDegFromRotationMatrix(float R[][3], float *pfPhiDeg, float *pfTheDeg, float *pfPsiDeg, float *pfRhoDeg, float *pfChiDeg)
extract the Android angles in degrees from the Android rotation matrix
int16_t iYs[3]
average measurement (counts)
void fRun_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal)
float flpf
low pass filter coefficient
Quaternion fq
unfiltered orientation quaternion
This is the 3DOF basic accelerometer state vector structure.
Quaternion fqPl
a posteriori orientation quaternion
float fLPR[3][3]
low pass filtered orientation matrix
#define GTOMSEC2
standard gravity in m/s2
float fRhoPl
compass (deg)
int8_t resetflag
flag to request re-initialization on next pass
float fR[3][3]
unfiltered orientation matrix
float fK6x3[6][3]
kalman filter gain matrix K
The GyroSensor structure stores raw and processed measurements for a 3-axis gyroscope.
float fDelta
unfiltered inclination angle (deg)
Math approximations file.
void fRun_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel)
float fChiPl
tilt from vertical (deg)
float fChiPl
tilt from vertical (deg)
float fQw9x9[9][9]
covariance matrix Qw
float fAlphaOver2
PI / 180 * fdeltat / 2.
float fdeltat
sensor fusion interval (s)
void fWin8AnglesDegFromRotationMatrix(float R[][3], float *pfPhiDeg, float *pfTheDeg, float *pfPsiDeg, float *pfRhoDeg, float *pfChiDeg)
extract the Windows 8 angles in degrees from the Windows 8 rotation matrix
Quaternion fq
unfiltered orientation quaternion
void fQuaternionFromRotationVectorDeg(Quaternion *pq, const float rvecdeg[], float fscaling)
computes normalized rotation quaternion from a rotation vector (deg)
int32_t systick
systick timer
float fOmega[3]
angular velocity (deg/s)
float fLPR[3][3]
low pass filtered orientation matrix
SV_9DOF_GBY_KALMAN is the 9DOF Kalman filter accelerometer, magnetometer and gyroscope state vector s...
Magnetic Calibration Structure.
#define FLPFSECS_6DOF_GB_BASIC
SV_3DOF_Y_BASIC structure is the 3DOF basic gyroscope state vector structure.
void ARM_systick_start_ticks(int32 *pstart)